🐛 Fixes for onboarding initiation if already logged in, UI loading in the background #1188
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
prevent onboarding initiation if already logged in
Bug:
If already logged in and an nrelopenpath:// link is launched (either via "JOIN" button or external QR scan), onboarding will re-initiate.
Storage from the first login is not cleared before attempting a second login and that could cause major issues.
Fix:
Prevent onboarding if onboarding has already been initiated. When handling an external URL launch we first check the onboarding state to see if the user has already initiated onboarding (i.e. gotten past "WELCOME"). If so, we'll popup with a message.
I also renamed
handleOpenURL
in the AppContext. cordova-plugin-customurlscheme requires a function with this name on the window object, which is why I named it that before. However we use that function to handle raw tokens too; not just URLs, so it is a misnomer.Renamed it to
handleTokenOrUrl
; then defined window.handleOpenURL as a function that callshandleTokenOrUrl
with a joinMethod of 'external'. This allows customurlscheme to work while keeping our code descriptive + readable.prevent UI loading in background; refactor useAppState
useAppStateChange
only accepted a callback for onResume. Refactored this into a more versatile hookuseAppState
, which still allows optional onResume or onChange callbacks and also returns the underlying appState.This allows App.tsx to useAppState and return null if appState is not 'active'. in this case the App.tsx itself will still initialize but it will not have any children
TimelineContext will no longer be rendered while the app is in the background so it no longer needs to listen for app state changes.
usePermissionStatus will still listen for onResume via the new interface, since it is invoked in App.tsx.